package com.fzk.blog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fzk.blog.bean.BlogTagReference;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author fzk
 * @date 2021-08-21 11:11
 */
public interface BlogTagReferenceMapper extends BaseMapper<BlogTagReference> {
    @Select("select * from tbl_blog_tag_reference where flag=0 and blog_id=#{blogId}")
    List<BlogTagReference> getReferenceByBlogId(int blogId);

    @Select("select tag_id from tbl_blog_tag_reference where flag=0 and blog_id=#{blogId}")
    List<Integer> getTagIdListByBlogId(int blogId);

    @Update("update tbl_blog_tag_reference set flag=1,edit_by=#{loginId} where blog_id=#{blogId} and tag_id=#{tagId} and flag=0")
    int logicalDeleteByBlogIdTagId(Integer blogId, int tagId, int loginId);

    @Delete("delete from tbl_blog_tag_reference where blog_id=#{blogId} and tag_id=#{tagId} and flag=0")
    int realDeleteByBlogIdTagId(int blogId, int tagId, int loginId);

    @Update("update tbl_blog_tag_reference set flag=1,edit_by=#{loginId} where blog_id=#{blogId} and flag=0")
    int logicalDeleteByBlogId(int blogId, int loginId);

    @Delete("delete from tbl_blog_tag_reference where blog_id=#{blogId} and flag=0")
    int realDeleteByBlogId(int blogId);
}
